home *** CD-ROM | disk | FTP | other *** search
/ Netware Super Library / Netware Super Library.iso / mis_cnvt / ntx2dbf / ntxfunc.prg < prev    next >
Encoding:
Text File  |  1993-01-04  |  1.5 KB  |  65 lines

  1. ********
  2. * Function: FNTXCAT
  3. * Author  : Gary Blatt
  4. * Date    : April 14, 1989
  5. * Syntax  : FNTXCAT(<expC1>,<expC2>)
  6. *           where <expC1> = index file name, without extension
  7. *                 <expC2> = database filename to be inserted            
  8. * Usage   : Call this function after each index/reindex to insert dbf name
  9. *           into the ntx file. Then use program listntx to display info.
  10.  
  11. FUNCTION FNTXCAT
  12. PARAMETERS NTX_name,DBF_name
  13.  
  14. *** close index file if open
  15. set inde to
  16.  
  17. *** open index file
  18. inHANDLE = fopen("&ntx_name..ntx")
  19. if ferror() <> 0
  20.    set inde to &ntx_name
  21.    return .f.
  22. endif 
  23.  
  24. *** set up temporary output file
  25. outhandle= fcreate('tmp.fil')
  26.  
  27. *** get total file length
  28. FLEN = fseek(inHANDLE,0,2)
  29.  
  30. *** reset file pointer to beginning
  31. fseek(inHANDLE,0)
  32.  
  33. *** read 1st 1008 bytes & put into buffer1
  34. block=1008
  35. buffer=spac(1008)
  36. fread(inHANDLE,@buffer,block)
  37. buffer1 = buffer
  38.  
  39. *** move file pointer by 8 bytes & read rest of file into buffer2
  40. fseek(inhandle,8,1)
  41. block=flen-1016
  42. buffer=spac(flen-1016)
  43. fread(inhandle,@buffer,block)
  44. buffer2=buffer
  45.  
  46. *** set string for output file
  47. obuffer=buffer1+pad(dbf_name,8)+buffer2
  48.  
  49. *** write string to output file
  50. fwrite(outhandle,obuffer)
  51.  
  52. *** close input & output files
  53. fclose(inhandle)
  54. fclose(outhandle)
  55.  
  56. *** rename tmp.fil to original name
  57. erase &ntx_name..ntx
  58. rename tmp.fil to &ntx_name..ntx
  59.  
  60. *** reopen index file if called with open database
  61. if .not. empty(alias())
  62.    set inde to &ntx_name
  63. endif
  64. return .t.
  65.